<!DOCTYPE html>
<html>
<head>
	<title>Samba printing</title>
	<meta charset="utf-8">
	<link href="./manual.css" rel="stylesheet" type="text/css">
	<link href="./samba-printing.css" rel="stylesheet" type="text/css">
</head>
<body>
	<div id="container">
		<h1>Printing with Samba</h1>
		<p>
			Some builds of Puppy do not have the 'smbspool' utility (type "which smbspool" in a terminal to find out). There is a special CUPS driver script named 'smbw' which in turn uses the 'smbclient' utility to print. This is a valuable contribution from rcrsn51.
		</p>
		<section>
			<h2>PART 1: smbspool drop-in replacement</h2>
			<p>
				The device URI (Uniform Resource Identifier) format for smbspool is defined as:
			</p>
			<p style="font-size: 14px;">
				<b>smb://</b><i>[username[:password]@][workgroup/]</i><b>server</b><i>[:port]</i><b>/printer</b>
			</p>
				Please take note of the compulsory minimum in bold: <b>smb://</b> [username[:password]@] [workgroup/] <b>server</b> [:port] <b>/printer</b>
			</p>
			<p>
			<section>
				<h3>Examples:</h3>
				<ol>
					<li>smb://PRINTSERVER/HP4V <span class="note">(minimum parameter smb://server/printer)</span></li>
					<li>smb://192.168.1.2/ML1200 <span class="note">(same as #1 but using IP address)</span></li>
					<li>smb://zigbert:ladiesman217@/192.168.2.22:9191/MP250 <span class="note">(extended parameters with username, password and server port)</span></li>
					<li>smb://dogbert:majesty@SYHDP/DILBERT/LEDCOPIER <span class="note">(extended parameters with username, password and domain name)</span></li>
				</ol>
			</section>
			<section>
				<h3>Features:</h3>
				<ul>
					<li>Fully supports smb URI format. This allows the authentication details to be embedded within the URI.</li>
					<li>Allows printing to multiple authenticated servers without mucking with separate authentication files.</li>
					<li>Supports print copies option, if required.</li>
					<li>Supports smbclient from both samba and samba-tng.</li>
				</ul>
			</section>
		</section>
		<section>
			<h2>PART 2: Getting CUPS to work with Windows print servers</h2>
			<p>
				<i>Extract from: <a href="http://willem.engen.nl/projects/cupssmb/">http://willem.engen.nl/projects/cupssmb/</a><br>
				by  Willem van Engen</i>
			</p>
			<p>
				CUPS uses <a href="http://www.samba.org/samba/docs/man/manpages-3/smbspool.8.html">smbspool(8)</a> to print pages to windows servers. This did not appear to work, whereas printing with <a href="http://www.samba.org/samba/docs/man/manpages-3/smbclient.1.html">smbclient(1)</a> did (some relief). Wanting to get it working, I created a custom CUPS backend that uses the latter instead of the former. This also allowed me to solve the problem of the windows password being visible in the device uri (which is shown in the web interface). <i>Note that this still is a work in progress: it is being used with success, but now and then I encounter issues.</i> This page will be updated accordingly.
			</p>
			<p>
				Following are sections for using the aforementioned programs. The final section gives a possible solution for using windows print servers with CUPS when smbspool(8) isn't working.
			</p>
			<section>
				<h3>Printing with smbspool</h3>
				<p>
					A CUPS <a href="http://www.cups.org/documentation.php/man-backend.html">backend(7)</a> is a program, usually located in <span class="path">/usr/lib/cups/backend/</span>, that sends a job to a printer or print server. CUPS uses smbspool(8), which is part of <a href="http://www.samba.org/">samba</a>, to spool jobs to windows servers. To this end, there is a symbolic link from <span class="path">/usr/lib/cups/backend/smb</span> to <span class="path">/usr/bin/smbspool</span>.
				</p>
				<p>
					To test the backend, it is possible to invoke smbspool(8) by hand. For example:
					<code>DEVICE_URI="smb://server/printer" smbspool 1234 me sometitle 1 &lt;test.ps</code>
				</p>
			</section>
			<section>
				<h3>Printing with smbclient</h3>
				<p>
					It is also possible to use smbclient(1) to print. When logging into a printer share on a windows server, one can issue the <span class="cmd">print</span> command to print a file. For example:
					<code>
						<div>smbclient -W <i>Domain</i> -U <i>me</i> <i>//server/printer</i></div>
						<div>Added interface ip=<i>xxx.xxx.xxx.xxx</i> bcast=<i>xxx.xxx.xxx.xxx</i> nmask=<i>xxx.xxx.xxx.xxx</i></div>
						<div>Password: <i>password</i></div>
						<div>Domain=[<i>Domain</i>] OS=[<i>Windows Server 2003 3790 Service Pack 2</i>] Server=[<i>Windows Server 2003 5.2</i>]</div>
						<div>smb: \&gt; print <i>test.ps</i></div>
						<div>printing file <i>test.ps</i> as <i>test.ps</i></div>
						<div><i>xxxxx</i> bytes printed</div>
						<br>
						<div>smb: \&gt; quit</div>
					</code>
				</p>
			</section>
			<section>
				<h3>A CUPS backend using smbclient</h3>
				<p>
					When smbspool(8) doesn't work, it may be possible to get printing working with smbclient(1).
				</p>
				<p>
					You should still create the file <span class="path">/etc/samba/printing.auth</span> containing your windows credentials, like this:
					<ul class="code">
						<li>username = s<i>123456</i></li>
						<li>password = <i>mypassword</i></li>
						<li>domain   = TUE</li>
					</ul>
					To protect it from prying eyes, make it owned by user <span class="cmd">cupsys</span> (or whatever CUPS backends are run by on your system) and make it readable for that user only. For <a href="http://www.ubuntu.com/">Ubuntu</a> users: this user is <span class="cmd">cupsys</span> on Feisty, but <span class="cmd">lp</span> on Gutsy.
				</p>
				<p>
					Remains to setup CUPS. I recommend to add a printer using the <a href="http://localhost:631/">web interface</a> with a device uri with protocol <span class="cmd">smbw</span>, like <span class="cmd">smbw://physfp.phys.tue.nl/n-IS2060PS</span>
				</p>
				<p>
					If you happen to use <a href="http://en.opensuse.org/Apparmor">AppArmor</a> in enforcing mode, you'll need to add <span class="cmd">#include &lt;abstractions/samba&gt;</span> to the <span class="cmd">cupsd</span> profile.
				</p>
			</section>
		</section>
		<footer class="legal">This page composed by Barry Kauler July 2010, modified: Michael Amadio 2014</footer>
	</div>
</body>
</html>